class Solution {
    public int[] exchange(int[] nums) {
        int left=0;
        int right=nums.length-1;
        while(left<=right){
            while(left<=right){
                if(nums[left]%2==1){
                    left++;
                }else{
                    break;
                }
            }
            while(left<=right){
                if(nums[right]%2==0){
                    right--;
                }else{
                    break;
                }
            }
            int tmp=nums[left];
            nums[left]=nums[right];
            nums[right]=tmp;
        }
       return nums;
    }
}